<div class="panel panel-custom editor">
    <div class="panel-heading editor">数据模型管理-{{item.schema_name}}
        <a ng-click="switchTreeSidebar()" class="show-sidebar">
            <i class="fa fa-bars"></i>
        </a>
        <a ng-click="gotoDefault()" class="go-default">
            <i class="glyphicon glyphicon-search"></i>
        </a>
    </div>
    <div class="panel-body schema-edit-form">
        <form role="form" editable-form class="form-content" name="schema_Form">
            <div class="form-group">
                <label for="schema_code" class="control-label col-xs-2">模型编码</label>
                <div class="col-xs-10">
                    <input type="text" ng-model="item.schema_code" class="form-control" unique-schema-code
                           required name="schema_code" id="schema_code" placeholder="数据模型编码">
                </div>
            </div>
            <div class="text-center">
                <span ng-show="schema_Form.schema_code.$error.schema_code_unique" class="form_error">模型编码重复.</span>
            </div>
            <div class="form-group">
                <label for="schema_name" class="control-label col-xs-2">模型名称</label>
                <div class="col-xs-10">
                    <input type="text" ng-model="item.schema_name" class="form-control"
                           required name="schema_name" id="schema_name" placeholder="数据模型名称">
                </div>
            </div>
            <div class="form-group">
                <label for="schema_name" class="control-label col-xs-2">模型列</label>
                <div class="col-xs-10">
                    <table class="editable_table">
                        <thead>
                        <tr>
                            <th style="width:20%">模型编码</th>
                            <th style="width:30%">模型名称</th>
                            <th style="width:20%">数据类型</th>
                            <th style="width:20%">分析类型</th>
                            <th style="width:10%"></th>
                        </tr>
                        </thead>
                        <tbody>
                        <tr ng-repeat="column in columns | filter:filterColumn">
                            <td>
                                <span editable-text="column.Code" e-name="Code" e-form="schema_Form" e-required>
                                  {{ column.Code || '未设置' }}
                                </span>
                            </td>
                            <td>
                                <span editable-text="column.Name" e-name="Name" e-form="schema_Form" e-required>
                                  {{ column.Name || '未设置' }}
                                </span>
                            </td>
                            <td>
                                <span editable-select="column.DataType" e-ng-change="changeDataType(column,$data)" e-name="DataType" e-form="schema_Form" e-required e-ng-options="type.value as type.text for type in schemaDataTypes">
                                  {{ showDataType(column) }}
                                </span>
                            </td>
                            <td>
                                <span editable-select="column.AnalysisType" e-name="AnalysisType" e-form="schema_Form" e-required e-ng-options="type.value as type.text for type in schemaAnalysisTypes">
                                  {{ showAnalysisType(column) }}
                                </span>
                            </td>
                            <td>
                                <button type="button" ng-show="schema_Form.$visible" ng-click="removeColumn($index)" class="btn btn-danger pull-right">移除</button>
                            </td>
                        </tr>
                        </tbody>
                    </table>
                    <div class="btn-edit">
                        <button type="button" class="btn btn-default" ng-show="!schema_Form.$visible" ng-click="schema_Form.$show()">
                            编辑
                        </button>
                    </div>
                    <div class="btn-form" ng-show="schema_Form.$visible">
                        <button type="button" ng-disabled="schema_Form.$waiting" ng-click="addColumn()" class="btn btn-default pull-right">新增</button>
                        <button type="submit" ng-disabled="schema_Form.$waiting" class="btn btn-primary">确定</button>
                        <button type="button" ng-disabled="schema_Form.$waiting" ng-click="cancelColumn()" class="btn btn-default">取消</button>
                    </div>
                </div>
            </div>
            <div class="form-group">
                <label class="control-label col-xs-2">数据集</label>
                <div class="col-xs-10">
                    <table class="edittable">
                        <thead>
                        <tr>
                            <th ng-show="false">ID</th>
                            <th>数据集编码</th>
                            <th>数据集名称</th>
                            <th>操作</th>
                        </tr>
                        </thead>
                        <tbody>
                        <tr ng-repeat="dataset in datasets">
                            <td ng-show="false">{{dataset.dataset_id}}</td>
                            <td>{{dataset.dataset_code}}</td>
                            <td>{{dataset.dataset_name}}</td>
                            <td>
                                <button ng-disabled="schema_Form.$dirty" class="btn btn-sm btn-info" ng-click="editDataset(item,dataset)">
                                    <i class="glyphicon glyphicon-edit">
                                    </i>
                                    编辑
                                </button>
                                <button ng-disabled="schema_Form.$dirty" class="btn btn-sm btn-danger" ng-click="deleteDataset(dataset)">
                                    <i class="glyphicon glyphicon-trash">
                                    </i>
                                    删除
                                </button>
                            </td>
                        </tr>
                        </tbody>
                    </table>
                    <div class="btn-form">
                        <button type="button" ng-click="addDataset(item)" class="btn btn-default pull-right" ng-disabled="schema_Form.$dirty">新增</button>
                    </div>
                </div>
            </div>
        </form>
    </div>
    <div class="panel-footer text-center">
        <button class="btn btn-success" type="button" ng-disabled="schema_Form.schema_code.$invalid || schema_Form.schema_name.$invalid" ng-click="save()">保存</button>
    </div>
</div>